<template>
	<sc-contextmenu ref="contextmenu" @command="handleCommand">
		<ButtonIcon
			v-for="button in menu"
			v-bind:key="button.id"
			:button="button"
			:gridEvents="gridEvents"
			:grid="grid"
		></ButtonIcon>
	</sc-contextmenu>
</template>

<script setup>
import scContextmenu from "@/components/scContextmenu";
import ButtonIcon from "./ButtonIcon";
import { ref } from "vue";
const props = defineProps({
	menu: {
		type: Array,
		default: () => [],
	},
	grid: {},
	gridEvents: {},
});

const handleCommand = (a) => {
	props.grid.triggerToolbarBtnEvent(a);
};
const contextmenu = ref();
const handleContextMenu = (e) => {
	contextmenu.value.openMenu(e);
};
defineExpose({
	handleContextMenu,
});
</script>
